#define _CRT_SECURE_NO_WARNINGS 
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	return 0;
}
//#include<bits/stdc++.h>
//using namespace std;
//using ULL = unsigned long long;
//const int x = 13331;
//int main()
//{
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	string s = "abcde";
//	ULL hash_code = s[0];
//	for (int i = 1; i < s.size(); i++) hash_code = hash_code * x + s[i];
//	cout << hash_code;
//	return 0;
//}
#include<bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;
const int X = 13331;
vector<ULL>h, x;
void BKDR_hash(string s)
{
	h[0] = s[0];
	x[0] = 1;
	for (int i = 1; i < s.size(); i++)
	{
		h[i] = h[i - 1] * X + s[i];
		x[i] = x[i - 1] * X;
	}
}
ULL get_hash(int left, int right)
{
	if (!left) return h[right];
	else
	{
		return h[right] - h[left - 1] * x[right - left + 1];//abde ab * x
	}
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	h.resize(s.size());
	x.resize(s.size());
	BKDR_hash(s);
	string ss;
	cin >> ss;
	ULL hash2 = 0;
	for (int i = 0; i < ss.size(); i++) hash2 = hash2 * X + ss[i];
	for (int i = -; i < s.size(); i++) cout << get_hash(i, min(s.size() - 1, i + ss.size() - 1)) << " ";
	cout << endl;
	cout << hash2;
	return 0;
}